﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL;
using System.Text.RegularExpressions;
using System.Text;

public partial class bwjc_Bwmsg : System.Web.UI.Page
{
    string type = "";
    public string show = "";

    BLLData bd = new BLLData();

    protected void Page_Load(object sender, EventArgs e)
    {
        string ID_KEY = HttpUtility.UrlDecode(Request.QueryString["id1"]);
        string para = HttpUtility.UrlDecode(Request.QueryString["type1"]);
       
        if (para == "gs")
            type = "计算公式";
        else if (para == "cs")
            type = "公式参数";

        if (!IsPostBack)
        {

            if (ID_KEY != "")
            {
                DataRow dr = bd.RetRTPointTable(ID_KEY);

                show = dr[type].ToString();
            }
        }
    }

    public string GetFirstString(string stringToSub, int length)
    {
        Regex regex = new Regex("[\u4e00-\u9fa5]+", RegexOptions.Compiled);
        char[] stringChar = stringToSub.ToCharArray();
        StringBuilder sb = new StringBuilder();
        int nLength = 0;
        bool isCut = false;
        for (int i = 0; i < stringChar.Length; i++)
        {
            if (regex.IsMatch((stringChar[i]).ToString()))
            {
                sb.Append(stringChar[i]);
                nLength += 2;
            }
            else
            {
                sb.Append(stringChar[i]);
                nLength = nLength + 1;
            }

            if (nLength > length)
            {
                isCut = true;
                break;
            }
        }
        if (isCut)
            return sb.ToString() + ". . .";
        else
            return sb.ToString();

    }
}
